package yz.mr.sort;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * 需求：
 *      将所有的学生的数据按照分数进行排序
 */
public class SortDriver {
    public static void main(String[] args) throws Exception{

        //1.创建Job操作对象
        //2.创建配置类对象
        Configuration entries = new Configuration();
        Job job = Job.getInstance(entries);

        //3.配置job
        job.setJobName("SortDriver");
        job.setJarByClass(SortDriver.class);

        //4.设置Mapper以及输出类型
        job.setMapperClass(SortMapper.class);
        job.setOutputKeyClass(SortStudent.class);
        job.setOutputValueClass(NullWritable.class);

        //6.设置最终地输出数据类型
        job.setOutputKeyClass(SortStudent.class);
        job.setOutputValueClass(NullWritable.class);

        //7.设置输入输出路径(这是本地的路径)  输入路径既可以指定路径也可以指定目录
        FileInputFormat.addInputPath(job,new Path("output/ReduceCount"));
        FileOutputFormat.setOutputPath(job,new Path("output/Sort2"));

        //8.提交执行当前JOB
        job.waitForCompletion(true);

    }
}
